package com.edu.exam.enums.assessment.generation;

/**
 * 审批状态枚举
 *
 * @author System
 * @version 1.0.0
 */
public enum ApprovalStatus {
    PENDING("PENDING", "待审批"),
    APPROVED("APPROVED", "已审批"),
    REJECTED("REJECTED", "已拒绝"),
    DRAFT("DRAFT", "草稿"),
    CANCELLED("CANCELLED", "已取消"),
    WITHDRAWN("WITHDRAWN", "已撤回"),
    EXPIRED("EXPIRED", "已过期"),
    IN_REVIEW("IN_REVIEW", "审批中"),
    REQUIRES_REVISION("REQUIRES_REVISION", "需要修改"),
    AUTO_APPROVED("AUTO_APPROVED", "自动审批");

    private final String code;
    private final String description;

    ApprovalStatus(String code, String description) {
        this.code = code;
        this.description = description;
    }

    public String getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    public static ApprovalStatus fromCode(String code) {
        for (ApprovalStatus status : ApprovalStatus.values()) {
            if (status.code.equals(code)) {
                return status;
            }
        }
        throw new IllegalArgumentException("Unknown approval status code: " + code);
    }

    @Override
    public String toString() {
        return description;
    }
}
